<?php

require_once 'ConfigEditorHandler.php';

function handle_admin_email()
{
	global $config;

	$config_file = $config['dir.install'].'etc/config.php';
	$req = new AdminEmailConfigEditor(array('source'=>$config_file));
	if ($req->init()) return call_user_func($req->dispatch());
} // end of function handle_check

class AdminEmailConfigEditor extends ConfigEditorHandler
{
	public $params = array('admin_email');
	public function confirm ()
	{
		global $config;

		// предварительные тесты прошли успешно, рисуем форму для ввода данных
		$key = request_get_param('d', NULL);
		if (!isset($key)) {
			return disp_email_verification_failed();
		}
		$data = digest_get($key);
		if (!isset($data) || !isset($data['vhash'])) {
			return disp_email_verification_failed();
		}
		$form = $this->getForm();
		$this->save($data['vhash']);
		disp_email_verification_success($data);
	} // end of method confirm
	public function loadDefaults ($form)
	{
	} // end of method getFormDefaults
	public function validate_admin_email ($f)
	{
		return install_validate_admin_email($f);
	} // end of method validate_admin_email
}
